package com.bems.dao;

import java.sql.SQLException;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ScalarHandler;

public class WareDao extends BaseDao 
{

	
			public double getTotal(int type) 
			{
				String sql ="SELECT sum(`quantity`) FROM `bems_ware` where type_id=?";
				QueryRunner _g_runner = new QueryRunner();
				try {
					Double r = _g_runner.query(getConnection(),sql, new ScalarHandler<Double>(), type);
					return r;
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
				
				return 0;
				
			}
			
			public static void main(String[] args) {
				WareDao wareDao = new WareDao();
				System.out.println(wareDao.getTotal(1));
			}
}
